home *** CD-ROM | disk | FTP | other *** search
- /**************************************************************************
- * *
- * Copyright (c) 1991 Silicon Graphics, Inc. *
- * All Rights Reserved *
- * *
- * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF SGI *
- * *
- * The copyright notice above does not evidence any actual of intended *
- * publication of such source code, and is an unpublished work by Silicon *
- * Graphics, Inc. This material contains CONFIDENTIAL INFORMATION that is *
- * the property of Silicon Graphics, Inc. Any use, duplication or *
- * disclosure not specifically authorized by Silicon Graphics is strictly *
- * prohibited. *
- * *
- * RESTRICTED RIGHTS LEGEND: *
- * *
- * Use, duplication or disclosure by the Government is subject to *
- * restrictions as set forth in subdivision (c)(1)(ii) of the Rights in *
- * Technical Data and Computer Software clause at DFARS 52.227-7013, *
- * and/or in similar or successor clauses in the FAR, DOD or NASA FAR *
- * Supplement. Unpublished - rights reserved under the Copyright Laws of *
- * the United States. Contractor is SILICON GRAPHICS, INC., 2011 N. *
- * Shoreline Blvd., Mountain View, CA 94039-7311 *
- **************************************************************************
- *
- * File: printers.c
- *
- * Description: Prints a list of the printers available under each of the
- * available spooling systems.
- *
- **************************************************************************/
-
-
- #ident "$Revision: 1.1 $"
-
-
- #include <stdio.h>
- #include <stdlib.h>
- #include "spool.h"
-
-
- void print_info(SLPrinterStruct*);
-
-
- main()
- {
- int i, num_printers;
- SLPrinterStruct *printers; /* Refer to SLGetPrinterList(3) man page */
- char *pname;
-
- /*
- * Get BSD known printers and default
- */
- if (SLSetSpooler(SL_SPOOLER_BSD) >= 0) {
- if (SLGetPrinterList(&printers, &num_printers) < 0) {
- SLPerror("printers");
- exit(1);
- }
- (void)printf("BSD Printers (%d):\n", num_printers);
- for (i = 0; i < num_printers; i++)
- print_info(&printers[i]);
- (void)printf("\nBSD Default Printer:\n");
- if (SLGetDefPrinterName(&pname) < 0 && pname) {
- SLPerror("printers");
- exit(1);
- }
- if (pname)
- (void)printf("\t%s\n", pname);
- else
- (void)printf("\tNone\n");
- }
-
- (void)printf("\n");
-
- /*
- * Get Sys V known printers
- */
- if (SLSetSpooler(SL_SPOOLER_SYSV) >= 0) {
- if (SLGetPrinterList(&printers, &num_printers) < 0) {
- SLPerror("printers");
- exit(1);
- }
- (void)printf("System V Printers (%d):\n", num_printers);
- for (i = 0; i < num_printers; i++)
- print_info(&printers[i]);
- (void)printf("\nSystem V Default Printer:\n");
- if (SLGetDefPrinterName(&pname) < 0 && pname) {
- SLPerror("printers");
- exit(1);
- }
- if (pname)
- (void)printf("\t%s\n", pname);
- else
- (void)printf("\tNone\n");
- }
-
- return 0;
- }
-
-
- void print_info(SLPrinterStruct *ptr)
- {
- (void)printf("\n");
- (void)printf("\tName:\t\t%s\n", ptr->local_name);
- (void)printf("\tFormal Name:\t%s\n", ptr->formal_name);
- (void)printf("\tType:\t\t%s\n", ptr->type);
- (void)printf("\tDefault:\t%s\n", (ptr->is_def) ? "Yes": "No");
- (void)printf("\tClass:\t\t%s\n", (ptr->is_class) ? "Yes": "No");
- if (ptr->is_networked) {
- (void)printf("\tRemote host:\t%s\n", ptr->remote_host);
- (void)printf("\tRemote name:\t%s\n", ptr->remote_name);
- } else {
- (void)printf("\tDevice:\t\t%s\n", ptr->dev);
- }
- }
-